package algorithm.array;

/**
 * https://leetcode.com/problems/reverse-string/submissions/
 * Easy
 *
 * 反转字符串，利用异或原地交换元素的思路
 *
 * Created by yzy on 2021-03-04 11:57
 */
public class ReverseString {

    public void reverseString(char[] s) {
        int i=0,j=s.length-1;
        while(i<j){
            s[i] = (char)(s[i]^s[j]);
            s[j] = (char)(s[i]^s[j]);
            s[i] = (char)(s[i]^s[j]);
            i++;
            j--;
        }
    }
}
